package com.fgchen.study.thread;

import java.util.concurrent.CountDownLatch;

/**
 * Created by fgchen on 2017/7/20.
 */
public class CountDownLatchDemo {

    public static void main(String[] args) throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    latch.await();
                    for (int i=0; i<10; i++) {
                        System.out.println(i);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        Thread.sleep(3000);
        latch.countDown();
    }

}
